"use strict";
exports.__esModule = true;
var Bus = /** @class */ (function () {
    function Bus() {
        this.list = {};
    }
    // 订阅
    Bus.prototype.emit = function (name) {
        var _this = this;
        var args = [];
        for (var _i = 1; _i < arguments.length; _i++) {
            args[_i - 1] = arguments[_i];
        }
        var eventName = this.list[name];
        eventName.forEach(function (fn) {
            fn.apply(_this, args);
        });
    };
    // 发布
    Bus.prototype.on = function (name, callback) {
        var fn = this.list[name] || [];
        fn.push(callback);
        this.list[name] = fn;
    };
    // 取消订阅
    Bus.prototype.off = function (name) {
        if (this.list[name]) {
            delete this.list[name];
        }
    };
    return Bus;
}());
exports["default"] = new Bus();
